package com.sinoglobal.dumping.dumplingdialog;

import android.view.View;

import com.sinoglobal.dumping.view.Dumpling_GetMoneyDialog;

/**
 * Created by KeZhuang on 2016/1/14.
 */
public class DumplingMoneyDialog extends DumplingDialogHelper implements DumplingIDialogFactory {
    @Override
    public Dumpling_GetMoneyDialog makeDialog(DumplingDialogHelper helper) {
        super.setValue(helper);
        Dumpling_GetMoneyDialog.Builder builder = getBuilder();
        builder.setType(Dumpling_GetMoneyDialog.TYPE_MONEY)
                .setBtnLeftVISIBLE(View.VISIBLE)
                .setBtnRightVISIBLE(View.VISIBLE)
                .setBtnLeftText(getLogin() ? "马上分享" : "去领取")
                .setBtnRightText("继续捞")
                .setCoreField(getDumplingVo().getPrizeAmount() + "元");
        if(getCount()==0){
            builder.setBtnLeftVISIBLE(getLogin() ? View.VISIBLE : View.GONE)
                    .setBtnRightVISIBLE(View.VISIBLE)
                    .setBtnLeftText(getLogin() ? "马上分享" : "")
                    .setBtnRightText(getLogin() ? "去钱包" : "去领取")
                    .setToast(getLogin() ? (getShare() < 2 && getMoney() > 0.0 ? "马上分享,再得一次机会" : "机会用完啦") : "马上领钱,再得一次机会");
        }
        builder.setOnClick(new Dumpling_GetMoneyDialog.GetMoneyOnSureClick() {
            @Override
            public void onCloseClick() {
            }

            @Override
            public void onBtnLeftClick() {
                leftButtonClick();
            }

            @Override
            public void onBtnRightClick() {
                if(getCount()==0){
                    if(getLogin()){
                        goWallet();
                    }else{
                        getDumpling(getContext());
                    }
                }else if(getLogin()){
                    loginAcquireDumpling();
                }else{
                    acquireDumpling();
                }
            }
        });
        return builder.builder();
    }
}
